package org.apache.jsp.manager.category;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import manager.category.*;
import java.util.*;

public final class CategoryList_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html;charset=euc-kr");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");


	CategoryListBean clb = new CategoryListBean();
	clb.getCate1();
	ArrayList cate1List = clb.getDataList();
	
	clb.getCate2();
	ArrayList cate2List = clb.getDataList();



      out.write("\r\n");
      out.write("\r\n");
      out.write("<SCRIPT language=\"JavaScript\">\r\n");
      out.write("\t// 마테고리 수정 페이지 가기\r\n");
      out.write("\tfunction goUpdate(seq, cate1Name)\r\n");
      out.write("\t{\r\n");
      out.write("\t\tdocument.location.href=\"/servlet/service.CategoryManagerServlet?func=category_005&seq=\"+seq+\"&cate1Name=\"+cate1Name;;\r\n");
      out.write("\t}\r\n");
      out.write("\r\n");
      out.write("\t// 카테고리 사용 or 삭제 하기\r\n");
      out.write("\tfunction useYnAction(seq, yn)\r\n");
      out.write("\t{\r\n");
      out.write("\t\tvar alertStr = \"선택하신 게시판을 사용하지 못하게 하시겠습니까?\";\r\n");
      out.write("\t\tif(yn=='Y')\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\talertStr = \"선택하신 게시판을 사용 하시겠습니까?\";\r\n");
      out.write("\t\t}\r\n");
      out.write("\t\tif(confirm(alertStr))\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\tdocument.location.href=\"/servlet/service.CategoryManagerServlet?func=category_004&yn=\"+yn+\"&seq=\"+seq;\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("\r\n");
      out.write("\t// 게시판 추가\r\n");
      out.write("\tfunction goAdd()\r\n");
      out.write("\t{\r\n");
      out.write("\t\tdocument.location.href=\"/servlet/service.CategoryManagerServlet?func=category_002\";\r\n");
      out.write("\t}\r\n");
      out.write("</SCRIPT>\r\n");
      out.write("\r\n");
      out.write("<CENTER>\r\n");
      out.write("\t<TABLE cellspacing=\"0\" cellpadding=\"0\">\r\n");
      out.write("\t\t<TR><TD height=\"25\"></TD></TR>\r\n");
      out.write("\t</TABLE>\r\n");
      out.write("\t<TABLE cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#7682EB\" width=\"250\">\r\n");
      out.write("\t\t<TR>\r\n");
      out.write("\t\t\t<TD align=\"center\" bgcolor=\"#CFDDFA\" width=\"250\">\r\n");
      out.write("\t\t\t\t<FONT color=\"blue\" size=\"3\"><B>카테고리 목록</B></FONT>\r\n");
      out.write("\t\t\t</TD>\r\n");
      out.write("\t\t</TR>\r\n");
      out.write("\t</TABLE>\r\n");
      out.write("\t<TABLE cellspacing=\"0\" cellpadding=\"0\" width=\"650\">\r\n");
      out.write("\t\t<TR>\r\n");
      out.write("\t\t\t<TD align=\"right\">\r\n");
      out.write("\t\t\t\t<IMG src=\"/images/button/button_add.gif\" border=\"0\" onclick=\"goAdd();\" style=\"cursor:hand\" align=\"absmiddle\">\r\n");
      out.write("\t\t\t</TD>\r\n");
      out.write("\t\t</TR>\r\n");
      out.write("\t\t<TR><TD height=\"3\"></TD></TR>\r\n");
      out.write("\t</TABLE>\r\n");
      out.write("\t<TABLE cellspacing=\"1\" cellpadding=\"3\" bgcolor=\"#7682EB\" width=\"650\">\r\n");
      out.write("\t\t<TR bgcolor=\"#CFDDFA\" align=\"center\">\r\n");
      out.write("\t\t\t<TD width=\"50\" ><B>순번</B></TD>\r\n");
      out.write("\t\t\t<TD width=\"100\"><B>1차카테고리</B></TD>\r\n");
      out.write("\t\t\t<TD width=\"100\"><B>2차카테고리</B></TD>\r\n");
      out.write("\t\t\t<TD width=\"100\"><B>작성자</B></TD>\r\n");
      out.write("\t\t\t<TD width=\"100\"><B>사용 여부</B></TD>\r\n");
      out.write("\t\t\t<TD width=\"100\"><B>기 능</B></TD>\r\n");
      out.write("\t\t</TR>\r\n");

	for(int i=0; i<cate1List.size(); i++)
	{
		Hashtable cate1Table = (Hashtable)cate1List.get(i);
		String seq = (String)cate1Table.get("SEQ");
		String cate1Name = (String)cate1Table.get("NAME");
		String useYn = (String)cate1Table.get("USEYN");
		String reg_id = (String)cate1Table.get("REG_ID");
		
		String bgcolor = "#FFFFFF";
		if(useYn.equals("N"))
		{
			bgcolor = "#E0E0E0";
		}

		String useKor = "사용중";
		if(useYn.equals("N"))
		{
			useKor = "미사용";
		}	

      out.write("\r\n");
      out.write("\t\t<TR bgcolor=\"");
      out.print( bgcolor);
      out.write("\">\r\n");
      out.write("\t\t\t<TD align=\"center\" rowspan=\"1\"><A href=\"javascript:goUpdate('");
      out.print( seq);
      out.write('\'');
      out.write(',');
      out.write('\'');
      out.print( cate1Name);
      out.write("')\"><B>");
      out.print( seq);
      out.write("</B></A></TD>\r\n");
      out.write("\t\t\t<TD align=\"center\" rowspan=\"1\"><A href=\"javascript:goUpdate('");
      out.print( seq);
      out.write('\'');
      out.write(',');
      out.write('\'');
      out.print( cate1Name);
      out.write("')\">");
      out.print( cate1Name);
      out.write("</A></TD>\r\n");
      out.write("\t\t\t<TD align=\"center\"></TD>\r\n");
      out.write("\t\t\t<TD align=\"center\">");
      out.print(reg_id );
      out.write("</TD>\r\n");
      out.write("\t\t\t<TD align=\"center\">");
      out.print( useYn);
      out.write("</TD>\r\n");
      out.write("\t\t\t<TD align=\"center\">\t\t\t\t\r\n");
      out.write("\t\t\t<IMG src=\"/images/button/sbut_update.gif\" align=\"absmiddle\" border=\"0\" style=\"cursor:hand\" onClick=\"goUpdate('");
      out.print( seq);
      out.write('\'');
      out.write(',');
      out.write('\'');
      out.print( cate1Name);
      out.write("')\">\r\n");

			if(useYn.equals("Y"))
			{

      out.write("\r\n");
      out.write("\t\t\t\t<IMG src=\"/images/button/sbut_delete.gif\" align=\"absmiddle\" border=\"0\" style=\"cursor:hand\" onClick=\"useYnAction('");
      out.print( seq);
      out.write("', 'N');\">\r\n");

			}
			else
			{			

      out.write("\r\n");
      out.write("\t\t\t\t<IMG src=\"/images/button/sbut_use.gif\" align=\"absmiddle\" border=\"0\" style=\"cursor:hand\" onClick=\"useYnAction('");
      out.print( seq);
      out.write("', 'Y');\">\r\n");

			}

      out.write("\r\n");
      out.write("\t\t\t</TD>\r\n");
      out.write("\t\t</TR>\r\n");
 	
		for(int j=0; j<cate2List.size(); j++)
		{
			Hashtable cate2Table = (Hashtable)cate2List.get(j);
			String cate2Name = (String)cate2Table.get("NAME");
			String group_seq = (String)cate2Table.get("GROUP_SEQ");	
			if(seq.equals(group_seq))
			{

      out.write("\r\n");
      out.write("\t\t\t<TR bgcolor=\"");
      out.print( bgcolor);
      out.write("\">\r\n");
      out.write("\t\t\t<TD align=\"center\" rowspan=\"1\"></TD>\r\n");
      out.write("\t\t\t<TD align=\"center\" rowspan=\"1\"></TD>\r\n");
      out.write("\t\t\t<TD align=\"center\">");
      out.print(cate2Name );
      out.write("</TD>\r\n");
      out.write("\t\t\t<TD align=\"center\"></TD>\r\n");
      out.write("\t\t\t<TD align=\"center\"></TD>\r\n");
      out.write("\t\t\t<TD align=\"center\">\t\t\r\n");

			}
		}
	}			

      out.write("\r\n");
      out.write("\t\r\n");
      out.write("\t\t\r\n");
      out.write("\r\n");
      out.write("\t\t\r\n");

	if(cate1List.size()==0)
	{

      out.write("\r\n");
      out.write("\t\t<TR><TD align=\"center\" bgcolor=\"#FFFFFF\" colspan=\"7\"><B>등록된 카테고리가 없습니다.</B></TD></TR>\r\n");

	}

      out.write("\r\n");
      out.write("\t</TABLE>\r\n");
      out.write("\r\n");
      out.write("</CENTER>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
